/**
 * 2013-6-21 下午5:50:13 Created By niexiaoqiang
 */

package com.xiaoqiang.util;

import android.content.Context;
import android.os.Looper;
import android.view.Gravity;
import android.widget.Toast;

/**
 * 公共类，吐丝打印
 */
public class MtwToast {

	private Context context;

	public MtwToast(Context context) {
		this.context = context;
	}

	public void show(String msg, boolean longtime) {
		new TocatShowThread(msg, longtime).start();
	}

	class TocatShowThread extends Thread {
		private String msg;
		private boolean longtime;

		public TocatShowThread(String msg, boolean longtime) {
			this.msg = msg;
			this.longtime = longtime;
		}

		public void run() {
			Looper.prepare();
			int showlong = Toast.LENGTH_SHORT;
			if (longtime) {
				showlong = Toast.LENGTH_LONG;
			}
			Toast toast = Toast.makeText(context, msg, showlong);
			toast.setGravity(Gravity.BOTTOM, 0, 0);
			toast.show();
			Looper.loop();
		}
	}
}
